package bluetooth;

public class Connection  
{
    Server server;
    Client client;
    boolean isServer;
    private FightCanvas myCanvas;
    boolean isAttack; boolean isObject;boolean isSkill; int skill; boolean isEscape;
    
    public Connection(FightCanvas myCanvas, boolean isServer)
    {
        this.myCanvas = myCanvas;
        this.isServer = isServer;      
    }

    public void start()
    {
        if (isServer)
        {
            server = new Server(this);
            server.start();
        }
        else
        {
            client = new Client(this);
            client.start();
        }
    }

    public void completeInitialization(boolean isBTReady)
    {
        myCanvas.completeInitialization(isBTReady);
    }


    public void sendMessage(boolean isAttack, boolean isObject,boolean isSkill, int skill, boolean isEscape)
    {
        if (isServer)
            server.sendMessage(isAttack,isObject,isSkill,skill,isEscape);
        else      
            client.sendMessage(isAttack,isObject,isSkill,skill,isEscape);
    }

    public void receiveMessage(boolean isAttack0, boolean isObject0,boolean isSkill0, int skill0, boolean isEscape0)
    {
        isAttack = isAttack0;
        isObject = isObject0;
        isSkill = isSkill0;
        skill = skill0;
        isEscape = isEscape0;
        System.out.println("connection is receivemessage");
        myCanvas.receiveMessage();
    }



    public boolean getisAttack()
    {
        return isAttack;
    }

    public boolean getisObject()
    {
        return isObject;
    }
    
    public boolean getisSkill()
    {
        return isSkill;
    }
    
    public int getskill()
    {
    	return skill;
    }
    
    public boolean getisEscape()
    {
        return isEscape;
    }

}
